{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "f0e41093",
   "metadata": {},
   "source": [
    "# 生成数组"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "9f6b6582",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "12f87091",
   "metadata": {},
   "outputs": [],
   "source": [
    "ones=np.ones([4,8])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "6d5d5015",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1., 1., 1., 1., 1., 1., 1., 1.],\n",
       "       [1., 1., 1., 1., 1., 1., 1., 1.],\n",
       "       [1., 1., 1., 1., 1., 1., 1., 1.],\n",
       "       [1., 1., 1., 1., 1., 1., 1., 1.]])"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ones"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "294ce2d4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0., 0., 0., 0., 0., 0., 0., 0.],\n",
       "       [0., 0., 0., 0., 0., 0., 0., 0.],\n",
       "       [0., 0., 0., 0., 0., 0., 0., 0.],\n",
       "       [0., 0., 0., 0., 0., 0., 0., 0.]])"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.zeros_like(ones)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "0fe71a94",
   "metadata": {},
   "outputs": [],
   "source": [
    "a=np.array([[1,2,3],[4,5,6]])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "5c24e74e",
   "metadata": {},
   "outputs": [],
   "source": [
    "a1=np.array(a)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "fab73f5d",
   "metadata": {},
   "outputs": [],
   "source": [
    "a2=np.asarray(a)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "dda4377f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1, 2, 3],\n",
       "       [4, 5, 6]])"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "cca4654b",
   "metadata": {},
   "outputs": [],
   "source": [
    "a[0,0]=100"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "8a6ca440",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1, 2, 3],\n",
       "       [4, 5, 6]])"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "9e30bd74",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[100,   2,   3],\n",
       "       [  4,   5,   6]])"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "9cc235d6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([  0.,  10.,  20.,  30.,  40.,  50.,  60.,  70.,  80.,  90., 100.])"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.linspace(0,100,11)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "23061e6e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42,\n",
       "       44, 46, 48])"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.arange(10,50,2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "183cfce8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([  1.,  10., 100.])"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.logspace(0,2,3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "7c9d8a03",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0.02688413, 0.46376985, 0.05883759],\n",
       "       [0.42733821, 0.32282356, 0.55850756]])"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.random.rand(2,3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "c8308ac4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[2.6972997 , 5.80523059, 5.74879345, 7.94718597, 3.06372099],\n",
       "       [2.57568286, 4.69899792, 6.33866528, 1.12875839, 9.60349252],\n",
       "       [6.45884175, 7.61613643, 3.35365418, 1.47490708, 1.56427208]])"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.random.uniform(low=1,high=10,size=(3,5))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "2439bd27",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[4, 9, 1, 7, 9],\n",
       "       [1, 4, 2, 5, 2],\n",
       "       [7, 2, 4, 3, 2]])"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.random.randint(1,10,(3,5))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "bfc6ee44",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
